/*    */ package com.eptok.yspay.opensdkjava.util;
/*    */ 
/*    */ import java.util.logging.Logger;
/*    */ import sun.misc.BASE64Decoder;
/*    */ import sun.misc.BASE64Encoder;
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DesUtil
/*    */ {
/* 11 */   private static Logger log = Logger.getLogger("DesUtil");
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static String encryptExtraData(String key, String charset, String extraData) throws Exception {
/* 18 */     String out = "";
/* 19 */     log.info("before-encryptExtraData:" + extraData);
/* 20 */     log.info("encryptExtraData-key:" + key);
/*    */     try {
/* 22 */       if (!StringUtil.isEmpty(key) && key.length() > 8) {
/* 23 */         key = key.substring(0, 8);
/*    */       }
/* 25 */       JDES jd = new JDES();
/* 26 */       jd.SetKey(key.getBytes(charset));
/* 27 */       out = new String((new BASE64Encoder()).encode(jd.doECBEncrypt(extraData
/* 28 */               .getBytes(charset), (extraData
/* 29 */               .getBytes(charset)).length)));
/* 30 */     } catch (Exception e) {
/* 31 */       throw e;
/*    */     } 
/* 33 */     return out;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static String decryptExtraData(String key, String charset, String encryptExtraData) throws Exception {
/* 41 */     String out = "";
/* 42 */     log.info("befor-decryptExtraData:" + encryptExtraData);
/* 43 */     log.info("decryptExtraData-key:" + key);
/*    */     try {
/* 45 */       if (!StringUtil.isEmpty(key) && key.length() > 8) {
/* 46 */         key = key.substring(0, 8);
/*    */       }
/* 48 */       JDES jd = new JDES();
/* 49 */       jd.SetKey(key.getBytes(charset));
/* 50 */       byte[] encryptByte = (new BASE64Decoder()).decodeBuffer(encryptExtraData);
/* 51 */       out = new String(jd.doECBDecrypt(encryptByte, encryptByte.length), charset);
/* 52 */     } catch (Exception e) {
/* 53 */       throw e;
/*    */     } 
/* 55 */     return out;
/*    */   }
/*    */ }


/* Location:              D:\repository\io\github\ysgatesdk\yspay-opensdk-java\1.0.1\yspay-opensdk-java-1.0.1.jar!\com\eptok\yspay\opensdkjav\\util\DesUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */